﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace VirtuOS.Components.Commands
{
    class uptime
    {
        public static string help = "Outputs the current uptime.";
        public static string register_name = "uptime";
        public static bool requires_root = false;

        public static void Command(string[] args)
        {
            if ((args.Length > 0) && (Regex.Match(args[0], @"(-)?-help", RegexOptions.IgnoreCase).Success))
            {
                Console.WriteLine(help);
            }
            else
            {
                string uptime = string.Empty;
                uptime = Convert.ToString(Environment.TickCount / 86400000) + " days, ";
                uptime = uptime + Convert.ToString(Environment.TickCount / 3600000 % 24) + " hours, ";
                uptime = uptime + Convert.ToString(Environment.TickCount / 60000 % 60) + " minutes, ";
                uptime = uptime + Convert.ToString(Environment.TickCount / 1000 % 60) + " seconds.";
                Console.WriteLine(TextHandler.UpperFirst(Environment.MachineName.ToLower()) + " uptime: " + uptime);
            }
        }
    }
}
